/*
 * @Author: 胡海
 * @Date: 2020-11-23 15:00:54
 * @LastEditors: 胡海
 * @LastEditTime: 2020-11-23 15:03:35
 * @Description: 
 */
var list = [
	{
		title:"吃饭打豆豆",
		isChecked:false 
	},
	{
		title:"妙味课堂",
		isChecked:true  
	}
];

new Vue({
	el:".main",
	data:{
		list:list,
		todo:"",
		edtorTodos:'',  
		beforeTitle:'' 
	},
	computed:{
		noCheckeLength:function(){
			return this.list.filter(function(item){
                return !item.isChecked
            }).length
		}
	},
	methods:{
		addTodo(){  
			this.list.push({
				title:this.todo,
				isChecked:false
			});
			this.todo = '';
		},
		deleteTodo(todo){ 
			var index = this.list.indexOf(todo);
			this.list.splice(index,1);
		},
		edtorTodo(todo){  
			console.log(todo);
		
			this.beforeTitle = todo.title;

			this.edtorTodos = todo;


		},
		edtorTodoed(todo){ 
			this.edtorTodos = '';
		},
		cancelTodo(todo){  

			todo.title = this.beforeTitle;

			this.beforeTitle = '';

			
			this.edtorTodos = '';
		}
	},
	directives:{
		"foucs":{
			update(el,binding){
				if(binding.value){
					el.focus();
				}
			}
		}
	}
});